package io.renren.modules.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.app.dao.BsDrugDao;
import io.renren.modules.app.entity.BsDrugEntity;
import io.renren.modules.app.service.BsDrugService;
import org.springframework.stereotype.Service;
import java.util.Map;



@Service("bsDrugService")
public class BsDrugServiceImpl extends ServiceImpl<BsDrugDao, BsDrugEntity> implements BsDrugService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        LambdaQueryWrapper<BsDrugEntity> wrapper = new LambdaQueryWrapper<>();

        if (params.get("drugName") != null && !params.get("drugName").equals("")){
            wrapper.like(BsDrugEntity::getDrugName,params.get("drugName"));
        }
        if (params.get("drugType") != null && !params.get("drugType").equals("")){
            wrapper.eq(BsDrugEntity::getDrugType,params.get("drugType"));
        }
        if (params.get("drugReagtype") != null && !params.get("drugReagtype").equals("")){
            wrapper.eq(BsDrugEntity::getDrugReagtype,params.get("drugReagtype"));
        }
        IPage<BsDrugEntity> page = this.page(
                new Query<BsDrugEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}
